import tkFont
import Tkinter
import datetime
import os
import __builtin__ as builtins

from application import application
from browser . gui import browser_gui
from browser . logic import browser_logic
from clockwork import clockwork
from copy_menu import copy_menu
from creation_menu import creation_menu
from edit_menu import edit_menu
from editor . gui import editor_gui
from editor . logic import editor_logic
from editor . logic . state_creating_new_query import editor_logic_state_creating_new_query
from editor . logic . state_editing_query import editor_logic_state_editing_query
from editor . logic . state_typing_existing_kb_type import editor_logic_state_typing_existing_kb_type
from editor . logic . state_typing_new_kb_type import editor_logic_state_typing_new_kb_type
from filesystem import filesystem
from gui import gui
from gui . consts import gui_consts
from knowledge_base import knowledge_base
from knowledge_base_directory import knowledge_base_directory
from knowledge_base_fetcher import knowledge_base_fetcher
from localization . english import localization_english
from localization . russian import localization_russian
from logic import logic
from main_loop import main_loop
from main_menu import main_menu
from menu . gui import menu_gui
from menu . logic import menu_logic
from mediator import mediator
from open_menu import open_menu
from rename_menu import rename_menu
from resources import resources
from resources . autogenerated import resources_autogenerated
from save_as_menu import save_as_menu
from scheduler import scheduler
from table_gui import table_gui
from welcome . gui import welcome_gui
from welcome . logic import welcome_logic

def chosen_localization ( ) :
    return localization_russian

class facade :
    def __init__ ( self ) :
        self . _scheduler = scheduler ( )
        self . _mediator = mediator ( )
        self . _mediator . register_modules \
            ( application = application ( self . _mediator )
            , browser_gui = browser_gui ( self . _mediator )
            , browser_logic = browser_logic ( self . _mediator )
            , clockwork = clockwork ( self . _mediator , datetime )
            , copy_menu = copy_menu ( self . _mediator )
            , creation_menu = creation_menu ( self . _mediator )
            , edit_menu = edit_menu ( self . _mediator )
            , editor_gui = editor_gui ( self . _mediator )
            , editor_logic = editor_logic ( self . _mediator )
            , filesystem = filesystem ( mediator = self . _mediator , builtins = builtins , os = os )
            , gui = gui ( mediator = self . _mediator , tkinter = Tkinter , tkfont = tkFont , scheduler = self . _scheduler )
            , gui_consts = gui_consts ( tkinter = Tkinter )
            , knowledge_base_directory = knowledge_base_directory ( self . _mediator )
            , knowledge_base_fetcher = knowledge_base_fetcher ( self . _mediator )
            , localization = chosen_localization ( ) ( )
            , logic = logic ( self . _mediator )
            , main_menu = main_menu ( self . _mediator )
            , menu_gui = menu_gui ( self . _mediator )
            , menu_logic = menu_logic ( self . _mediator )
            , open_menu = open_menu ( self . _mediator )
            , rename_menu = rename_menu ( self . _mediator )
            , resources = resources ( resources_autogenerated )
            , save_as_menu = save_as_menu ( self . _mediator )
            , table_gui = table_gui ( self . _mediator )
            , welcome_gui = welcome_gui ( self . _mediator )
            , welcome_logic = welcome_logic ( self . _mediator )
            
            , editor_logic_state_creating_new_query = self . _scheduler . module ( editor_logic_state_creating_new_query ( self . _mediator ) )
            , editor_logic_state_editing_query = self . _scheduler . module ( editor_logic_state_editing_query ( self . _mediator ) )
            , editor_logic_state_typing_existing_kb_type = self . _scheduler . module ( editor_logic_state_typing_existing_kb_type ( self . _mediator ) )
            , editor_logic_state_typing_new_kb_type = self . _scheduler . module ( editor_logic_state_typing_new_kb_type ( self . _mediator ) )
            , knowledge_base = self . _scheduler . module ( knowledge_base ( self . _mediator ) )
            , main_loop = self . _scheduler . module ( main_loop ( self . _mediator ) )
            )
    def start ( self ) :
        self . _scheduler . run ( self . _mediator . start )
        self . _scheduler . run ( self . _mediator . run_main_loop )
